package cn.ml.gaoJi.nDeJie;

import java.util.Scanner;

public class JieCheng {
    public static void main(String[] args) {
        for (int i = 0; i < 100; i++) {
            Scanner input = new Scanner(System.in);
            System.out.println("请输入你想求的数：");
            int num = input.nextInt();
            if (num == 1) {
                System.out.println("1的阶乘为1!=1");
            } else {
                System.out.println(num + "的阶乘为" + num +"!=" + toString(num) + "=" + jie(num));
            }
        }
    }

    public static int jie(int n){
        if(n == 1){
            return 1;
        }else {
            return n * jie(n-1);
        }
    }

    public static String toString(int n) {
        if (n == 1) {
            return "1";
        } else {
            return toString(n-1) + "*" + n;
        }
    }
}
